﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
    // json 主要的标记有几个：{}、[]、""、：，{}是一个概况，成对出现，
    // []用于在一个{}中并列的几个项。每个名/值对由”“括起来。值和名称之间用：隔开
        function GetString() {
            var json = "{\"firstname\":\"lsyuan\",";
            json += "\"lastname\":\"lisy\"}";
            return json;
        }
        function pageload() {
            var json = GetString();
            eval("var employee = " + json+";");
            document.write(employee.firstname + employee.lastname);
        }
        window.employee = function window$employee(firstname, lastname) {
            this.firstname = firstname;
            this.lastname = lastname;
        }
    // 使用eval时注意数据的安全性
    </script>
</head>
<body onload="pageload()">
</body>
</html>
